﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
using FileParser;

namespace _2D_GUI
{
    /// <summary>
    /// Represents attributes within a project.
    /// </summary>
    class C_Triangle : C_Shape
    {
        // 3 points of a triangle
        private Point[] trianglePoints = new Point[3];

        /// <summary>
        /// Brief constructor.
        /// Creates a new C_Shape.
        /// </summary>
        /// <param name="orig"></param>
        /// <param name="triangleSize"></param>
        /// <param name="triangleLocation"></param>
        /// <param name="triangleColor"></param>
        /// <param name="shapes"></param>
        public C_Triangle( C_DataStructure orig, Size triangleSize, Point triangleLocation, Color triangleColor, C_Shape[] shapes)
            : base(orig, triangleSize, triangleLocation, triangleColor, shapes)
        {
        }

        /// <summary>
        /// Draws a triangle.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public override void Draw(object sender, PaintEventArgs e)
        {
            // Get equipment
            Graphics g = e.Graphics;
            // Set bounds
            Rectangle rect = new Rectangle(shapeLocation, shapeSize);
            // Calculate points of the triangle
            trianglePoints[0] = new Point(shapeLocation.X + shapeSize.Width / 2, shapeLocation.Y);
            trianglePoints[1] = new Point(shapeLocation.X, shapeLocation.Y + shapeSize.Height);
            trianglePoints[2] = new Point(shapeLocation.X + shapeSize.Width, shapeLocation.Y + shapeSize.Height);
            // Draw triangle
            g.FillPolygon(shapeBrush, trianglePoints);
            // Changes the color of inherited shapes
            for (int i = 0; i < shapeArray.Length; i++)
            {
                if (shapeColor == Color.Blue)
                    shapeArray[i].SetColor(Color.Red);
                else if (shapeColor == Color.Red)
                    shapeArray[i].SetColor(Color.LawnGreen);
                else if (shapeColor == Color.LawnGreen)
                    shapeArray[i].SetColor(Color.Yellow);
                else
                    shapeArray[i].SetColor(Color.Blue);
            }
            // Create a new frame in which to draw the inherited shapes in
            C_Frame childShapes = new C_Frame(shapeArray, shapeSize.Width, shapeSize.Height, shapeLocation);
            // Draw inherited shapes
            childShapes.Draw(sender, e);
        }

    }
}